# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo1423
# Description:  序列化过程
# Author:       yzl
# Date:         2019-02-10
#-------------------------------------------------------------------------------


import json

class Product:
    def __init__(self,name,price,count):
        self.name = name
        self.price = price
        self.count = count

def prodoct2json(obj):
    return {
        'name':obj.name,
        'price':obj.price,
        'count':obj.count
    }

p = Product('大众',140000,100)
jsonstr = json.dumps(p,default=prodoct2json,ensure_ascii=False)
print(jsonstr)